package com.iqiyi.pps.epg.web.utils;

import org.apache.commons.lang.StringUtils;
import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by IntelliJ IDEA.
 * User: Administrator
 * Date: 13-9-25
 * Time: 下午7:49
 * To change this template use File | Settings | File Templates.
 */
public class WebConstants {
    private static ObjectMapper mapper = new ObjectMapper();
    /**
     * is_success 成功值
     */
    public static final String IS_SUCCESS_TRUE = "T";
    /**
     * is_success 不成功值
     */
    public static final String IS_SUCCESS_FALSE = "F";
    public static final String ORDER_DEFAULT_EXPIRE_TIME = "24h";  //订单默认有效时间
    public static final String CODE_SUCCESS = "A00000"; //请求成功
    public static final String CODE_ERROR_INVALID = "L00002";//公共使用，参数格式不正确
    public static final String CODE_ERROR_NOT_NULL = "L00001";//参数非空
    public static final String CODE_ERROR_SERVER = "L00003";//服务器内部错误
    public static final String CODE_ERROR_GET_QIPU_ID_ERROR = "L10001";//获取奇谱id失败
    public static final String CODE_ERROR_SAVE_MAMS_ERROR = "L10002";//保存mams失败
    public static final String CODE_ERROR_SAVE_OPERATION_ERROR = "L10003";//保存operation失败
    public static final String CODE_ERROR_SAVE_CATEGORY_ERROR = "L10004";//保存层级结构失败
    public static final String CODE_ERROR_SAVE_IMAGE_ERROR = "L10005";//保存圖片失败
    public static final int TIME_SET_TYPE_QC = 0;//时间设置类型  0 审核  1 质检
    public static final int TIME_SET_TYPE_QA = 1;

    //客户类型
    /**
     * 真实用户
     */
    public static final int USER_TYPE_REAL = 1;
    /**
     * 虚拟用户
     */
    public static final int USER_TYPE_VIRTUAL = 2;
    /**
     * 体验用户
     */
    public static final int USER_TYPE_EXP = 3;
    /**
     * 渠道用户
     */
    public static final int USER_TYPE_CHANNEL = 4;
    /**
     * 标识是否有效的字段
     */
    public static final int CHN_EFFECT = 1;
    public static final int CHN_UNEFFECT = 0;
    public static final int COMMON_UNEFFECT = 0;
    public static final int COMMON_EFFECT = 1;
    //内容类型
    //状态
    public static final int STATUS_HIDDEN = -1;
    public static final int STATUS_FREEZE = 2;
    /**
     * 冻结
     */
    public static final int SERV_USER_STOP = 1;
    /**
     * 解冻
     */
    public static final int SERV_USER_UNSTOP = 0;
    public static final int QA_AUDIT_TYPE_ONE = 1;//一检
    public static final int QA_AUDIT_TYPE_TWO = 2;//二检
    public static final int NULL = -100;
    public static final int COMPANY_IQIYI = 2;//爱奇艺
    public static final int COMPANY_PPS = 4;//频道设置 品牌  pps
    public static Map<String, String> editorCodeMap = null;

    public static Map<Integer, String> getConnectionType() {
        Map<Integer, String> foo = new HashMap<Integer, String>();
        foo.put(30, "系列关系（如电视剧第几季）");
        foo.put(10, "不同配音版本");
        foo.put(40, "周边宣传关系");
        foo.put(20, "不同年代/主角版本");
        foo.put(50, "2D/3D");
        return foo;
    }

    public static Map<Integer, String> playType() {
        Map<Integer, String> foo = new HashMap<Integer, String>();
        foo.put(1, "4:3");
        foo.put(2, "16:9");
        return foo;
    }

    public static String getEditorCode(String key) {
        if (editorCodeMap == null) {
            synchronized (WebConstants.class) {
                if (editorCodeMap == null) {
                    editorCodeMap = new HashMap<String, String>();
                    editorCodeMap.put("1", "A00000"); // 通过
                    editorCodeMap.put("2", "L00201"); //出现异常
                    editorCodeMap.put("3", "L00202"); //参数错误
                    editorCodeMap.put("4", "L00203");  //素材状态不合法
                    editorCodeMap.put("5", "L00204"); //帧率必须完全相同
                    editorCodeMap.put("6", "L00205"); //分辨率必须完全相同
                    editorCodeMap.put("7", "L00206"); //视频编码格式必须完全相同
                    editorCodeMap.put("8", "L00207"); //图像格式必须完全相同
                    editorCodeMap.put("9", "L00208"); //音频编码格式必须完全相同
                    editorCodeMap.put("10", "L00209"); //音频采样率必须完全相同
                    editorCodeMap.put("11", "L00210"); //声道格式必须完全相同
                    editorCodeMap.put("12", "L00211");  //音频位宽必须完全相同
                    editorCodeMap.put("13", "L00212");  //地区必须完全相同
                }
            }
        }
        return editorCodeMap.get(key);
    }

    public static void main(String[] args) {
        System.out.println(ResourceType.getResourceTypeByValue(1).toString());
    }

    /**
     * lyw
     * 资源类型转换，0 节目  8 素材 6 图片  ,600  海报图  ,601  封面图     ,602  生活    ,603  剧照    ,604 人物图   ,605 头图 ,   699 其他

     */
    public enum ResourceType {
        wnbc(1);//TYPE_STREAM_FILE(2);//节目、素材、码流文件 、审核、质检
        static Map<Integer, ResourceType> instances = new HashMap<Integer, ResourceType>();

        static {
            instances.put(1, ResourceType.wnbc);
        }

        private int value;

        ResourceType(int value) {
            this.value = value;
        }

        public static ResourceType getResourceTypeByValue(Integer value) {
            return instances.get(value);
        }

        public int value() {
            return this.value;
        }

        public String toString() {
            return super.toString().toLowerCase();
        }

    }

    /**
     * 1 素材上传  2 成片制作  3 节目转码 4 安检系统审核  5 安检系统质检  6图片制作 7 图片转码 8 图片分发
     *
     * @author Dell
     */
    public enum WorkflowType {
        WNBC_UGCVIDEO_OFFLINE(1, "mams_ugc_offline");
        static Map<Integer, WorkflowType> instances = new HashMap<Integer, WorkflowType>();

        static {
            instances.put(1, WorkflowType.WNBC_UGCVIDEO_OFFLINE);
        }

        private int type;
        private String name;

        WorkflowType(int type, String name) {
            this.type = type;
            this.name = name;
        }

        public static WorkflowType getWorkflowType(int type) {
            return instances.get(type);
        }

        public int intValue() {
            return type;
        }

        public String toString() {
            return name;
        }
    }

    public static Map<Integer, String> gamePlatformMap=new HashMap<Integer, String>();
    public static Map<Integer, String> gameTypeMap=new HashMap<Integer, String>();

    static {
        gamePlatformMap.put(1, "网络游戏");
        gamePlatformMap.put(2, "竞技游戏");
        gamePlatformMap.put(3, "PC");
        gamePlatformMap.put(4, "iOS");
        gamePlatformMap.put(5, "Android");
        gamePlatformMap.put(6, "Windows");
        gamePlatformMap.put(7, "Phone");
        gamePlatformMap.put(8, "FC");
        gamePlatformMap.put(9, "SFC");
        gamePlatformMap.put(10, "MD");
        gamePlatformMap.put(11, "NGC");
        gamePlatformMap.put(12, "DC");
        gamePlatformMap.put(13, "PS1");
        gamePlatformMap.put(14, "PS2");
        gamePlatformMap.put(15, "PS3");
        gamePlatformMap.put(16, "PS4");
        gamePlatformMap.put(17, "Xbox");
        gamePlatformMap.put(18, "Xbox360");
        gamePlatformMap.put(19, "Xbox");
        gamePlatformMap.put(20, "One");
        gamePlatformMap.put(21, "Wii");
        gamePlatformMap.put(23, "WiiU");
        gamePlatformMap.put(24, "PSP");
        gamePlatformMap.put(25, "PSV");
        gamePlatformMap.put(26, "NDS");
        gamePlatformMap.put(27, "3DS");
        gamePlatformMap.put(28, "GB");
        gamePlatformMap.put(29, "GBA");




        gameTypeMap.put(1, "MMORPG");
        gameTypeMap.put(2, "MOBA");
        gameTypeMap.put(3, "RTS");
        gameTypeMap.put(4, "FPS");
        gameTypeMap.put(5, "FTG");
        gameTypeMap.put(6, "TPS");
        gameTypeMap.put(7, "RPG");
        gameTypeMap.put(8, "ARPG");
        gameTypeMap.put(9, "SLG");
        gameTypeMap.put(10, "ACT");
        gameTypeMap.put(11, "AVG");
        gameTypeMap.put(12, "RAC");
        gameTypeMap.put(13, "SPG");
        gameTypeMap.put(14, "PUZ");
        gameTypeMap.put(15, "其它 ");

    }

    public static String getJsonResponse(String code,Object value,String msg){
        Map<String, Object> map=new HashMap<String, Object>();
        map.put("code", code);
        if(value!=null){
            map.put("data", value);
        }
        if(StringUtils.isNotBlank(msg)){
            map.put("msg", msg);
        }

        String result =null;

        try {
            result=mapper.writeValueAsString(map);
        } catch (JsonGenerationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (JsonMappingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        return result;
    }

    public static int VIDEOUGC_STATUS_INIT = 1;
    public static int VIDEOUGC_STATUS_PROCESS = 2;
    public static int VIDEOUGC_STATUS_FINISH = 3;
    public static int VIDEOUGC_STATUS_KILL = 4;
    public static int VIDEOUGC_STATUS_FAIL = 5;

    public static Map<Integer, String> getStatusMap() {
        Map map = new HashMap<Integer, String>();
        map.put(VIDEOUGC_STATUS_INIT, "INIT");
        map.put(VIDEOUGC_STATUS_PROCESS, "PROCESS");
        map.put(VIDEOUGC_STATUS_FINISH, "FINISH");
        map.put(VIDEOUGC_STATUS_KILL, "KILL");
        map.put(VIDEOUGC_STATUS_FAIL, "FAIL");
        return map;
    }
}
